// pages/Access/LookLog/index.js

let app = getApp();
const HttpAjax = getApp().getHttpData;
import coindexArry from './../../../utils/DoorEvent.js'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    loadendtxt:'正在加载',
    key:'',
    currentDate: new Date().getTime(),
    // minDate: new Date().getTime(),
    show:false,
    allData:[],
    dN:'',
    lN:'',
    coindexArry:[]
  },
  onChange(event) {
    this.setData({
      currentDate: event.detail.value
    });
  },
  onSearch(){
    this.setData({
      show:true
    })
  },
  onClose(){
    console.log(123)
    this.setData({
      show: false
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(coindexArry);
    this.setData({
      key:options.door_id,
      dN: options.name,
      lN: options.lctn,
      coindexArry:coindexArry
    });
    let that=this;
    HttpAjax(app.globalData.url + '/Door/GetDoorRecord', { DoorID: options.door_id, CustomerID: options.CustomerID },
     'post', app.globalData.headerCookie)
      .then(ress => {
        console.log(ress);
        let res = ress.data;
        if(res.records){
          let data=res.records;
          let p
          for (let i=0;i<data.length; i++){
            p = coindexArry.filter((item,index)=>{
              if(item.index == data[i].rt){
                item.id=index;
                return item
              }
            })
            data[i].xtat=p[0]
          }
          console.log(data)
        }
        
        that.setData({
          allData: res.records
        })
      })
      .catch(err => {
        console.log(err)
      })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})